package com.hskn.hss.module.cases.to;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hskn.hss.utils.Tools;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Data
@ApiModel(value = "事件报表-TO", description = "事件报表-TO")
public class EventDistributionTO implements Serializable {
    @ApiModelProperty(value = "机构类型", name = "depType", example = "1")
    private String depType;
    @ApiModelProperty(value = "机构ID", name = "depId", example = "1")
    private String depId;
    @ApiModelProperty(value = "上报人ID", name = "userId", example = "1")
    private String userId;
    @ApiModelProperty(value = "责任人ID", name = "personId", example = "1")
    private String personId;
    @ApiModelProperty(value = "问题大类", name = "problemCategoryId", example = "1")
    private String problemCategoryId;
    @ApiModelProperty(value = "问题小类", name = "problemSubclassId", example = "1")
    private String problemSubclassId;
    @ApiModelProperty(value = "时间类型", name = "dateType", example = "1,2")
    private Integer dateType;
    @ApiModelProperty(value = "开始时间", name = "startTime", example = "2021-09-22")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startDate;
    @ApiModelProperty(value = "结束时间", name = "endTime", example = "2021-09-22")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endDate;
    @ApiModelProperty(value = "页数", name = "page", example = "1")
    private Integer page;
    @ApiModelProperty(value = "页面大小", name = "size", example = "10")
    private Integer size;
    @ApiModelProperty(value = "页数", name = "page", example = "1")
    private Integer pageNum;
    @ApiModelProperty(value = "页面大小", name = "size", example = "10")
    private Integer pageSize;

    @ApiModelProperty(value = "机构ID", name = "depId", example = "1")
    private List<String > depNames;
    @ApiModelProperty(value = "人员id", name = "depId", example = "1")
    private List<String > personIds;

    public Date getStartDate() {
        if (null != startDate) {
            return startDate;
        }
        return Tools.getFristDayForDate(new Date());
    }

    public Date getEndDate() {
        if (null != endDate) {
            return endDate;
        }
        return Tools.getLastDayForDate(new Date());
    }

    public Integer getPage() {
        if (Objects.isNull(page)){
            return 1;
        }
        return page;
    }

    public Integer getSize() {
        if (Objects.isNull(size)){
            return 20;
        }
        return size;
    }
}
